jQuery(function ($) {

    var swiper = new Swiper('.sec_top', {
        pagination: '.swiper-pagination',
        autoHeight: true,
        spaceBetween: 30,
        onSlideChangeStart: function (swiper) {
            $('.lis').eq(swiper.activeIndex).addClass('nav_li').siblings().removeClass('nav_li');
        }

    });
    $('.lis').click(function () {
        $(this).addClass('nav_li').siblings().removeClass('nav_li');
        swiper.slideTo($(this).index(), 1000);
        if($("nav_li").lenght ==0){
            $(".btn").css("opacity","0");
        }
    })

});
var swiper1 = new Swiper('.swipers .swiper-container', {
    // pagination: '.swiper-pagination',
    paginationClickable: true,
    // spaceBetween: 30,
    // centeredSlides: true,
    autoplay: 2500,
    autoplayDisableOnInteraction: false
});

var liH = $('#ul').children().eq(0).height()
var ulH = $('#ul').height()
var ulT = $('#ul').position().top
var count = 0;
var id = setInterval(function () {
    count -= liH;
    $("#ul").animate({ top: count + "px" }, 500, function () {
        if (ul.style.top == -(ulH - liH) + 'px') {
            count = 0;
            $("#ul").css("top", "0px");

        }
    })

}, 2000)


$.ajax({
    type: "get",
    url: "../json/index.json",
    dataType: 'json',
    success: function (arr) {

        var str = template("tem", {
            list: arr
        });

        $('.jsons').html(str);

    }
});
$(window).scroll(function () {
    var top = $(this).scrollTop();
    console.log(top)

    if (top > 200) {
        //  var ttp =  $('.top').offset().top;
        //  $('.top').offset().top;
        // $('.top').animate({top:-60})
        $('.header').slideUp()
    } else if (top < 100) {
        // $('.top').animate({top:0})
        $('.header').slideDown()
    }
})


$.ajax({
    type: "get",
    url: "../json/first.json",
    dataType: 'json',
    success: function (arr) {

        var str = template("img", {
            img: arr
        });

        $('.img').html(str);

    }
});
// var duixuan = document.getElementsById("#duixuan");
// var dui = document.getElementsByClassName(".dui");
$(".img>figure").click(function(){
    console.log(111);
    $(".duixuan").hide().siblings(".dui").show();
});

 